<?php
JLoader::register("PJobpositionModelPositions", OC_App::getAppPath('jobposition') . "/lib/positions.php");
JLoader::register("PCompanyModelThirdAccounts", OC::$SERVERROOT."/apps/company/lib/thirdaccounts.php");

$LoginStats = PUtil::checkUserLogin(true);
if ($LoginStats !== true) {
   echo $LoginStats;
   exit();
}

OCP\JSON::callCheck();

$model = new PJobpositionModelPositions();

$jobids = JRequest::getString('ids','');
$alljobids = JRequest::getVar('alljobis',array(),'','array');
$action = JRequest::getString('action','');

$sourcelist = $model->getSourcesByJobids($jobids,$action);

$model2 = new PCompanyModelThirdAccounts();
$sync_info = $model2->getCompanyThirdToolsInfo();
if(!$sync_info)
   $sync_info  = array();
$thirdaccounts_info = !empty($sync_info['login']) ? json_decode($sync_info['login'],true) : null;
$thirdaccounts_status = !empty($sync_info['status']) ? json_decode($sync_info['status'],true) : null;

$tmpl = new OCP\Template('jobposition', 'part.renew.dialog', '');
$tmpl->assign('jobids', $jobids);
$tmpl->assign('alljobids', $alljobids);
$tmpl->assign('action', $action);
$tmpl->assign('sourcelist',$sourcelist);
$tmpl->assign('thirdaccounts_info',$thirdaccounts_info);
$tmpl->assign('thirdaccounts_status',$thirdaccounts_status);
$tmpl->assign('masteruser', PFactory::isMasterUser());
$tmpl->printpage();
